import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_taotaoshipin/common/theme/app_colors.dart';
import 'package:flutter_taotaoshipin/util/global.dart';
import 'package:flutter_taotaoshipin/widget/base_dialog.dart';

class ConfirmOpenDialog extends StatelessWidget {
  const ConfirmOpenDialog({super.key, this.onSuccess});

  final VoidCallback? onSuccess;

  @override
  Widget build(BuildContext context) {
    return BaseDialog(
      title: '确认开通',
      onPressed: onSuccess,
      confirmBtnTitle: '同意',
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 16),
        child: Container(
          alignment: Alignment.centerLeft,
          child: RichText(
            text: TextSpan(
              text: "如需开通，请先同意",
              style: TextStyle(color: AppColors.text, fontSize: 14),
              children: [
                TextSpan(
                  text: "《会员用户协议》",
                  style: TextStyle(color: AppColors.app_main),
                  recognizer: TapGestureRecognizer()
                    ..onTap = () {
                      Global.openVipUserProtocol();
                    },
                ),
                TextSpan(text: '和'),
                TextSpan(
                  text: "《自动续费服务规则》",
                  style: TextStyle(color: AppColors.app_main),
                  recognizer: TapGestureRecognizer()
                    ..onTap = () {
                      Global.openAutoRenewPolicy();
                    },
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
